package com.controller.hht;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;

import com.bean.hht.Stuinfo;
import com.mapper.hht.AppointMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.Map;

@Controller
public class InterviewhtmlController {
    @Autowired
    AppointMapper appointMapper;

    @GetMapping("/invitation")
    public String invitation(@RequestParam("wxid")String wxid,Map<String,Object> map){

        QueryWrapper<Stuinfo> wrapper = new QueryWrapper<>();
        wrapper.eq("wxid",wxid);
        Stuinfo stu = appointMapper.selectOne(wrapper);
        if (stu==null){
            return "404";
        }
        else{
        String stu_name = stu.getName();
        String stu_intjob=stu.getIntjob();
        String interview_time=stu.getInterview_time();
        map.put("stu_name",stu_name);
        map.put("stu_intjob",stu_intjob);
        map.put("interview_time",interview_time);

        //classpath:/templates/invitation.xml
        return "invitation";
        }
    }
    @GetMapping("/offerletter")
    public String offerletter(@RequestParam("wxid")String wxid,Map<String,Object> map){

        QueryWrapper<Stuinfo> wrapper = new QueryWrapper<>();
        wrapper.eq("wxid",wxid);
        Stuinfo stu = appointMapper.selectOne(wrapper);
        if (stu==null){
            return "404";
        }
        else{
            String stu_name = stu.getName();
            String stu_intjob=stu.getIntjob();
            String interview_time=stu.getInterview_time();
            String groups = stu.getGroups();
            String grou="";
            if (groups.equals("CILG")){
                grou="湖北大学瑞翼工坊云与智能生活项目群（CILG）";
            }else if (groups.equals("QARG")){
                grou="湖北大学瑞翼工坊质量分析与可靠性项目群(QARQ)";
            }else if(groups.equals("TRI")){
                grou = "湖北大学瑞翼工坊技术研究院（TRI）";
            }else if (groups.equals("RPG")){
                grou = "湖北大学瑞翼工坊资源规划项目群(RPG)";
            }
            map.put("grou",grou);
            map.put("stu_name",stu_name);
            map.put("stu_intjob",stu_intjob);
            map.put("interview_time",interview_time);

            //classpath:/templates/invitation.xml
            return "offerletter";
        }
    }
}
